//
//  CellContentModel.m
//  XiangMuB
//
//  Created by lanou3g on 16/8/15.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "CellContentModel.h"


@implementation CellContentModel

- (NSMutableArray *)imageArray{
    
    if (_imageArray == nil) {
        _imageArray = [NSMutableArray array];
    }
    
    return _imageArray;
}

- (NSMutableArray *)tagArrays{
    
    if (_tagArrays == nil) {
        _tagArrays = [NSMutableArray array];
    }
    
    return _tagArrays;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    
    [aCoder encodeObject:self.textViewString forKey:@"textViewString"];
    [aCoder encodeObject:self.imageArray forKey:@"imageArray"];
    [aCoder encodeObject:self.tagArrays forKey:@"tagArrays"];
    
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    
    self = [super init];
    if (self) {

        
        self.textViewString = [aDecoder decodeObjectForKey:@"textViewString"];
        self.imageArray = [aDecoder decodeObjectForKey:@"imageArray"];
        self.tagArrays = [aDecoder decodeObjectForKey:@"tagArrays"];
        
    }
    return self;
}

+ (NSData *)archiveWithCellContentModel:(CellContentModel *)contentModel{
    
    NSMutableData *data = [NSMutableData data];
    
    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
    
    [archiver encodeObject:contentModel forKey:@"contentModel"];
    [archiver finishEncoding];
    
    return data;
}

+ (CellContentModel *)unarchiveWithCellContentData:(NSData *)contentData{
    
    NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:contentData];
    
    CellContentModel *model = [unarchiver decodeObjectForKey:@"contentModel"];
    
    [unarchiver finishDecoding];
    
    return model;
    
}





@end
